package qimao.com.edu.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.fasterxml.jackson.databind.ObjectMapper;
import qimao.com.edu.entity.CommenResult;
import qimao.com.edu.entity.Users;
import qimao.com.edu.service.UsersService;
import qimao.com.edu.service.impl.UsersServiceImpl;

@WebServlet("/admin/selectUser.do")
public class SelectUserServlet extends HttpServlet {
	
    private UsersService userService = new UsersServiceImpl();
    Users users = new Users();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("application/json;charset=UTF-8");
        CommenResult cr=new CommenResult();
        List<Users> userList = userService.getAllUsers();
        if(userList != null) {
        	cr.setCode(200);
        	cr.setData(userList);
        	resp.getWriter().write(cr.toJsonString());
        }
        System.out.println(userList);
    }
}